package com.jwell.panrank.application

import android.app.Application
import android.support.multidex.MultiDex
import com.iflytek.cloud.SpeechUtility
import com.jwell.cargoapp.tools.delegates.NotNullSingleValueVar
import com.jwell.panrank.R
import com.jwell.panrank.tools.StatuseBarUtils
import com.scwang.smartrefresh.layout.SmartRefreshLayout
import com.scwang.smartrefresh.layout.constant.SpinnerStyle
import com.scwang.smartrefresh.layout.footer.ClassicsFooter
import com.scwang.smartrefresh.layout.header.ClassicsHeader
import com.tencent.bugly.Bugly

/**
 * Created by老中医 on 2018/3/21.
 * QQ:765773123
 */
class App : Application() {
//class App : TinkerApplication {

    companion object {
//        var DEBUG = "http://221.237.162.142:13420/" != RetrofitFactory.BASE_URL
        var DEBUG = true
        var instance: App by NotNullSingleValueVar.DelegatesExt.notNullSingleValue()
        var statusHeight: Int = -1

        init {

            //设置全局的Header构建器
            SmartRefreshLayout.setDefaultRefreshHeaderCreater { context, layout ->
                layout.setPrimaryColorsId(R.color.textColor, android.R.color.white)//全局设置主题颜色
                ClassicsHeader(context).setSpinnerStyle(SpinnerStyle.Translate)//指定为经典Header，默认是 贝塞尔雷达Header
            }
            //设置全局的Footer构建器
            SmartRefreshLayout.setDefaultRefreshFooterCreater { context, layout ->
                layout.setPrimaryColorsId(R.color.textColor, android.R.color.white)
                //指定为经典Footer，默认是 BallPulseFooter
                ClassicsFooter(context).setSpinnerStyle(SpinnerStyle.Translate)
            }
        }
    }

//    constructor() : super(ShareConstants.TINKER_ENABLE_ALL, "com.jwell.panrank.application.AppLike", "com.tencent.tinker.loader.TinkerLoader", false)

    override fun onCreate() {
        super.onCreate()
        instance = this
        statusHeight = StatuseBarUtils.getSTATUSTOOLHEIGHT(instance)
        Bugly.init(this, "70db8c4004", !App.DEBUG)
        MultiDex.install(this)
        //初始化Fresco
//        Fresco.initialize(instance)
        //初始化LeakCanary工具
//        if (!LeakCanary.isInAnalyzerProcess(instance)) LeakCanary.install(this)
        //初始化科大讯飞
        SpeechUtility.createUtility(applicationContext, "appid=5ad04cfe")
    }
}